const mongoose = require('mongoose');

const productSchema = new mongoose.Schema({
  // 产品名称
  name: {
    type: String,
    required: true,
    unique: true
  },
  
  // 产品标识 (用于API调用)
  code: {
    type: String,
    required: true,
    unique: true,
    index: true,
    uppercase: true
  },
  
  // 产品描述
  description: {
    type: String,
    default: ''
  },
  
  // 支持的语言列表
  supportedLocales: [{
    type: String,
    required: true
  }],
  
  // 默认语言
  defaultLocale: {
    type: String,
    required: true,
    default: 'zh-CN'
  },
  
  // Webhook URL (词条更新时通知)
  webhookUrl: {
    type: String,
    default: null
  },
  
  // 部署环境配置
  environments: {
    development: {
      version: String,
      cdnUrl: String
    },
    testing: {
      version: String,
      cdnUrl: String
    },
    production: {
      version: String,
      cdnUrl: String
    }
  },
  
  // 是否启用
  enabled: {
    type: Boolean,
    default: true
  }
}, {
  timestamps: true
});

module.exports = mongoose.model('Product', productSchema);

